package com.aliothservice.catfish.conf;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.mongodb.config.AbstractMongoConfiguration;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.data.mongodb.gridfs.GridFsTemplate;

import com.mongodb.Mongo;
import com.mongodb.MongoClient;

@Configuration
public class MongoConf extends AbstractMongoConfiguration {
	
	@Override
	protected String getDatabaseName() {
		return "catfish";
	}
	
	@Override
	public Mongo mongo() throws Exception {
		return new MongoClient("localhost");
	}
	
	@Bean
	@Override
	public MongoTemplate mongoTemplate() throws Exception {
		return super.mongoTemplate();
	}
	
	@Bean
	public GridFsTemplate gridFsTemplate() throws Exception {
		return new GridFsTemplate(mongoDbFactory(), mappingMongoConverter());
	}	

}
